<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>
    <style>
        .mdui-table-fluid {
            width: 1200px;
        }

        .mdui-table {
            border: 1px solid #d6d6d6;
        }

        .mdui-btn {
            margin-right: 100px;
        }

        a {
            text-decoration: none;
        }

        .mdui-table-fluid {
            width: 800px;
        }

        .mdui-table td img {
            height: 100px;
            width: 140px;
        }

        .mdui-btn1 {
            margin-top: 10px;
            width: 800px;
        }
    </style>

</head>

<body class="mdui-theme-primary-indigo mdui-theme-accent-pink">
<div class="mdui-container-fluid" id="app">
    <h3> {{door.name}}水电详情</h3>
    <button class="mdui-btn mdui-color-green-800 mdui-ripple"><a href="list.html"
                                                                 class=" mdui-color-green-800">返回上一级</a>
    </button>

    <div class="mdui-table-fluid">
        <table class="mdui-table">
            <thead>
            <tr>
                <th>类别</th>
                <th>用量</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>用水量</td>
                <td>
                    <div class="mdui-textfield">
                        <input class="mdui-textfield-input" type="text" v-model="door.ton"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td>用电量</td>
                <td>
                    <div class="mdui-textfield">
                        <input class="mdui-textfield-input" type="text" v-model="door.kilowatt"/>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <button class="mdui-btn mdui-btn1 mdui-color-green-800 mdui-ripple" @click="savedoor">确认提交</button>

</div>
</body>
<script>
    let params = new URLSearchParams(location.search);//location.searc url中参数的部分包括问号
    let doorname = params.get("name")
    console.log(doorname)
    new Vue({
        el: '#app',
        data: {
            door: {
                kilowatt: '',
                ton: ''
            },

        },
        created() {
            let _this = this
            axios.get("/door/findbyname?name=" + doorname)
                .then(function (res) {
                    _this.door = res.data;
                })
        },
        methods: {
            savedoor() {
                let _this = this;
                console.log(this.door)
                axios.post("/door/saveDoor", this.door)
                    .then(function (res) {
                        if (res.data.success) {
                            mdui.alert("提交成功");
                        }
                    })
            },
        }
    })
</script>
</body>
</html>